<script setup>
  import { onLoad } from '@dcloudio/uni-app'
  import { getUserTruck } from '@/apis/user'
  import { ref } from 'vue'

  const userTruckInfo = ref({})

  onLoad(async () => {
    const res = await getUserTruck()
    userTruckInfo.value = res.data
  })
</script>

<template>
  <view class="page-container">
    <swiper
      v-if="userTruckInfo.pictureList?.length > 0"
      class="truck-pictures"
      indicator-active-color="#fff"
      circular
      indicator-dots
    >
      <swiper-item v-for="(v, i) of userTruckInfo.pictureList" :key="i">
        <image class="picture" mode="aspectFill" :src="v.url"></image>
      </swiper-item>
    </swiper>
    <view class="truck-meta">
      <uni-list :border="false">
        <uni-list-item :border="false" title="车辆编号" :rightText="userTruckInfo.id" />
        <uni-list-item :border="false" title="车辆号牌" :rightText="userTruckInfo.licensePlate" />
        <uni-list-item :border="false" title="车型" :rightText="userTruckInfo.truckType" />
        <uni-list-item :border="false" title="所属机构" :rightText="userTruckInfo.currentOrganName" />
        <uni-list-item :border="false" title="载重(吨)" :rightText="userTruckInfo.allowableLoad" />
      </uni-list>
    </view>
  </view>
</template>

<style lang="scss" scoped>
  @import './index.scss';
</style>
